//全选记录
$("body").on("click", "input[name=all]", function(event) {
    if (this.checked) {
        $("#tb :checkbox").prop("checked", true);
        $("#patch-delete").removeAttr("disabled");
    } else {
        $("#tb :checkbox").prop("checked", false);
        $("#patch-delete").attr("disabled",true);
    }
});
//挑选记录
$("body").on("click", "input:checkbox", function(event) {
    if (this.checked) {
        $("#patch-delete").removeAttr("disabled");
    } else {
        $("#patch-delete").attr("disabled",true);
    }
});

//刷新
$("#refresh").bind('click', function(){
    loadingData();
})

//单条删除
$("body").on("click", ".delete-bt", function(event) {
    if (confirm("确定删除吗")) {
        var ids = [$(this).attr("data-id")];
        deleteRows(ids);
    }
})
//批量删除
$("#patch-delete").bind('click', function(){
    if (confirm("确定删除吗")) {
        var ids = [];
        $.each($('input[name=ids]'),function(){
            if(this.checked){
                ids.push($(this).val())
            }
        });
        deleteRows(ids);
    }
})

//翻页
$("body").on("click", "#more", function(event) {
    var page = $(this).attr("data-page");
    var next = parseInt(page)+1;
    $(this).attr("data-page", next);
    loadingData(page);
})
